package com.toprs.business.extend

import org.mybatis.dynamic.sql.BasicColumn
import org.mybatis.dynamic.sql.render.TableAliasCalculator
import java.util.*

class MonthColum(val q: Boolean) : BasicColumn {

    private var alias: String? = "month"

    override fun alias(): Optional<String> {
        return Optional.ofNullable(alias)
    }

    override fun `as`(alias: String?): BasicColumn {
        val v = MonthColum(q)
        v.alias = alias
        return v
    }

    override fun renderWithTableAlias(tableAliasCalculator: TableAliasCalculator?): String {
        return if (q) "to_char(t_application_report.report_time,'yyyy-mm')" else "month"
    }
}